﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Kenly.DBFramework.Gateway
{   
    /// <summary>
    /// Represents a attribute that contains metadata to describe the association between container and property.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public sealed class OneToOneAssociationAttribute : Attribute
    {
        /// <summary>
        /// 
        /// </summary>
        public OneToOneAssociationAttribute()
        {
        }

        /// <summary>
        /// AssociationType
        /// </summary>
        public static AssociationType AssociationType
        {
            get
            {
                return AssociationType.OneToOne;
            }
        }

        /// <summary>
        /// Converts to an Association.
        /// </summary>
        /// <param name="oneToOneAssociation"></param>
        /// <returns></returns>
        public static implicit operator AssociationAttribute(OneToOneAssociationAttribute oneToOneAssociation)
        {
            return ToAssociationAttribute();
        }

        /// <summary>
        /// Converts to an Association.
        /// </summary>
        /// <returns></returns>
        public static AssociationAttribute ToAssociationAttribute()
        {
            return new AssociationAttribute(AssociationType.OneToOne);
        }

    }
}
